/*
 * Created on 2022-08-04
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.di.ui.util;

import org.eclipse.swt.widgets.Shell;

/**
 * 窗体显示位置计算工具
 *
 * @author tanpeng@yzbdl.ac.cn
 * @date 2022-08-04 18:24
 */
public class DialogPositionUtil {

    /**
     * 设置窗体大小和位置
     * @param parent 父容器
     * @param width 宽
     * @param height 高
     * @param shell 壳子
     */
    public static void getXyPoint(Shell parent, int width, int height, Shell shell) {
        int parentWidth = parent.getBounds().width;
        int parentHeight = parent.getBounds().height;
        int parentX = parent.getBounds().x;
        int parentY = parent.getBounds().y;
        int xPoint = parentX + (parentWidth - width) / 2;
        int yPoint = parentY + (parentHeight - height) / 2;
        shell.setBounds(xPoint, yPoint, width, height);
    }
}
